package com.sk.bilibili.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.sk.bilibili.bean.Collect;
import com.sk.bilibili.bean.Type;
import com.sk.bilibili.dto.CollectInfo;
import com.sk.bilibili.other.R;
import com.sk.bilibili.service.CollectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @author 邵康
 * @date 2021/11/25 15:36
 */
@CrossOrigin
@RestController
@RequestMapping("/collect")
@Api(tags = "收藏")
public class CollectController {

    @Autowired
    private CollectService collectService;

    @ApiOperation("收藏视频  只能用于收藏视频 视频id必须  收藏夹id若不知道 收藏到默认收藏夹")
    @PostMapping("/add")
    public R<Collect> add(@RequestBody Collect collect) {
        return collectService.add(collect);
    }

    @ApiOperation("根据id删除收藏")
    @GetMapping("/delete")
    public R<Void> delete(Integer id) {
        return collectService.delete(id);
    }

    @ApiOperation("更新收藏  id必须   只能用于更新收藏夹Id")
    @PostMapping("/update")
    public R<Void> update(@RequestBody Collect collect) {
        return collectService.update(collect);
    }

    @ApiOperation("复制收藏到目标收藏夹")
    @GetMapping("/copy")
    public R<Void> copy(Integer[] ids,Integer favoritesId) {
        return collectService.copy(ids,favoritesId);
    }

    @ApiOperation("按分区类型 或排序类型 分页")
    @PostMapping("/pageType")
    public R<IPage<Collect>> pageType(@RequestBody CollectInfo collectInfo) {
        return collectService.pageType(collectInfo);
    }

    @ApiOperation("获取指定收藏夹下的各类型数量信息")
    @PostMapping("/getPageType")
    public R<List<Type>> getPageType(Integer favoritesId) {
        return collectService.getPageType(favoritesId);
    }

    @ApiOperation("搜索分页")
    @PostMapping("/pageSearch")
    public R<IPage<Collect>> pageSearch(@RequestBody CollectInfo collectInfo) {
        return collectService.pageSearch(collectInfo);
    }

}
